﻿@{
    ViewData["Title"] = "数据库管理";
}
<div class="text-center" id="app">
    <el-row class="btnrow">
        <el-button size="medium" icon="el-icon-plus" v-on:click="showAdd()">新增</el-button>
    </el-row>
    <el-table :data="tableData"
              style="width: 100%">
        <el-table-column v-for="col in columns" :prop="col.prop"
                         :label="col.label"
                         :width="col.width">
    </el-table>
    <el-dialog title="数据库连接信息" :visible="dialogFormVisible">
        <el-form :model="form">
            <el-form-item label="连接名称" :label-width="formLabelWidth">
                <el-input v-model="form.dbName" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="数据库类型" :label-width="formLabelWidth">
                <el-select v-model="form.dbType" placeholder="请选择活动区域">
                    <el-option label="MySql" value="MySql"></el-option>
                    <el-option label="SqlServer" value="SqlServer"></el-option>
                    <el-option label="Oracle" value="Oracle"></el-option>
                    <el-option label="PostgreSQL" value="PostgreSQL"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="数据库连接字符串" :label-width="formLabelWidth">
                <el-input v-model="form.dbConnectString" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button v-on:click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" v-on:click="Submit()">确 定</el-button>
        </div>
    </el-dialog>

</div>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            tableData: [],
            columns: [
                { prop: "dbName", label: "数据库名称", width: "200" },
                { prop: "dbType", label: "数据库类型", width: "300" },
                { prop: "dbConnectString", label: "数据库连接字符换" },
            ],
            formLabelWidth: 100,
            dialogFormVisible: false,
            form: { name: "", dbType: "", connectString: "" }
        },
        methods: {
            getdata() {
                let that = this;
                axios.post('/DataBase/List', {
                    TypeName: '二手房',
                }).then(function (response) {
                    console.log(response);
                    that.tableData = response.data.data;
                }).catch(function (error) {
                    console.log(error);
                });
            },
            showAdd() {
                this.dialogFormVisible = true; 
            },
            Submit() {

            }
        },
        created() {
            this.getdata();
        },
    });
</script>